package com.mapper;

import com.POJO.StudentClass;
import java.util.List;

import org.apache.ibatis.annotations.*;

/**
 * @Package com.mapper
 * @Date 2024-05-23 11:34
 * 学生-班级相关数据库操作
 */

@Mapper
public interface StudentClassMapper {
    @Select("select * from student_classes where student_id =#{studentId}")
    // 根据学生ID获取其所在的班级
    List<StudentClass> getStudentClassesByStudentId(int studentId);

    // 新增学生-班级关系
  @Insert("insert into student_classes(student_id,class_id) values (#{studentId},#{classId})")
  @Options(useGeneratedKeys = true, keyProperty = "studentId")
    void insertStudentClass(StudentClass studentClass);

    // 删除学生-班级关系
    @Delete("DELETE from student_classes where id=#{id}")
    void deleteStudentClass(int id);
}
